#!/bin/bash
read -p "请输入组名称：" GROUP

GROUPID=` cat /etc/group |awk -F ":" '{print $1 " " $3}'|grep "^$GROUP " |awk '{print $2}'        `
#获取组用户
echo "-----------------------"
echo "$GROUP 组中包含以下用户："
cat /etc/passwd |awk -F":" '{print $1 " " $4}'|grep  " $GROUPID"|awk '{print $1}' |sort|uniq >/tmp/sysuser
cat /etc/group |awk -F ":" '{print $4 " " $3}'|grep  " $GROUPID"|awk '{print $1}' |tr ","  "\n" >>/tmp/sysuser
cat /tmp/sysuser
echo "-----------------------"
